package com.dongnao.barry.ls38_rxjavaopertor.rxjava;


import android.util.Log;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//切换成
public class OnSubscribleOnIO<T>  implements  ObservableOnSubscribe<T>{
    private static ExecutorService executorService = Executors.newCachedThreadPool();
    Obserable<T> source;

    public OnSubscribleOnIO(Obserable<T> source) {
        this.source = source;
    }

    @Override
    public void subscribe(final Observer<? super T> observer) {
        Log.i("david", "OnSubscribleOnIO: ==============> subscribe--->  "+Thread.currentThread().getName());
        executorService.submit(new Runnable() {

            @Override
            public void run() {
                Log.i("david", "run: ======>"+Thread.currentThread().getName());
               source.subscrible(observer);
            }
        });
    }
}
